using System;
using Microsoft.SPOT;

namespace GizmoProject
{
    public class Board
    {
        private static Board instance;
        private Random random = new Random();

        public byte[][] board;
            /*= {{1,1,1,1,1,1,1,1,1,1},
                               {1,0,1,0,0,0,0,0,0,1},
                               {1,0,1,0,0,0,0,0,0,1},
                               {1,0,1,0,0,0,0,0,0,1},
                               {1,0,0,0,0,0,0,0,0,1},
                               {1,0,0,0,1,1,1,0,0,1},
                               {1,0,0,0,1,0,0,0,0,1},
                               {1,0,0,0,0,0,0,0,0,1},
                               {1,0,0,0,0,1,1,0,0,1},
                               {1,1,1,1,1,1,1,1,1,1}};
            */
        public int sizeX = 10;
        public int sizeY = 10;

        private Board()
        {
        }

        public static Board Instance
        {
            get
            {
                if ( instance == null )
                    instance = new Board();

                return instance;
            }
        }

        public bool IsEmpty( int x, int y )
        {
            return ( board[x][ y] == 0 );
        }

        public int[] GetRandomFreeCell()
        {
            int[] res = new int[2];
            do
            {
                res[0] = random.Next( sizeX );
                res[1] = random.Next( sizeY );
            }
            while ( !IsEmpty( res[0], res[1] ) );

            return res;
        }

    }
}
